/*
Run this script on:

        mssql-tl.db.jwan.it,14444.TTTLines2013    -  This database will be modified

to synchronize it with:

        kalgan01.cs.jwan.it,1443.Jambo2014_sviluppo

You are recommended to back up your database before running this script

Script created by SQL Compare version 9.0.0 from Red Gate Software Ltd at 02/04/2014 12:26:38

*/
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID('tempdb..#tmpErrors')) DROP TABLE #tmpErrors
GO
CREATE TABLE #tmpErrors (Error int)
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO
PRINT N'Altering [dbo].[v_jb_tariffe]'
GO
/* =============================================
 VM 08-08-2012 - Aggiornato alla nuova struttura
 AM 19/08/2010 
 Author:		Andrea Marchesini
 =============================================
INNER JOIN dbo.jb_tessere_tipo as ta WITH (NOLOCK) ON cs.TIPO_TESSERA = ta.TIPO_TESSERA*/
ALTER VIEW dbo.v_jb_tariffe
WITH ENCRYPTION AS
SELECT DISTINCT 
                      p.CATKEY, c.CODCAT, c.TIPO_CAT, cs.DESCRIZIONE, p.PREZZO, p.PREZZOAR, p.CODSCO, c.LUN_DEF, c.LUN_MIN, c.LUN_MAX, cs.GRUPPO, cs.QUOTA_GUIDA, 
                      cs.SCONTO_GUIDA, cs.QUOTA_PAX, cs.CATKEY_PAX, cs.VOUCHER, cs.OMAGGIO, cs.TIPO_TESSERA, cs.CTRLTKT, cs.ORDINE, p.CODVAL, p.CODTAR, 
                      p.COD_CFG_LIST, p.CODLIST, cc.IDCFG, cs.IS_PASSAGGIO_TESSERA, cs.RESIDENTE
FROM         dbo.jb_categoSconti AS cs WITH (NOLOCK) INNER JOIN
                      dbo.prezzi AS p WITH (NOLOCK) ON cs.CODSCO = p.CODSCO AND cs.CATKEY = p.CATKEY INNER JOIN
                      dbo.catego AS c WITH (NOLOCK) ON c.CATKEY = p.CATKEY INNER JOIN
                      dbo.configcatego AS cc WITH (NOLOCK) ON cc.CATKEY = c.CATKEY
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Altering [dbo].[v_EsportaAnek]'
GO


/* C.M. 2014-03-20 - aggiunta di macroregione e bts e modifiche alle join*/
ALTER VIEW [dbo].[v_EsportaAnek]
--WITH ENCRYPTION 
WITH ENCRYPTION AS

SELECT     m.SERIAL, m.CODAGE, a.NOME, a.AGEMADRE, a.DARENDICONTARE AS affidate, a.TIPO_BIGLIETTERIA, an.DESCRIZIONE AS network, 
                      ans.DATA_ENTRATA AS entrata_network, ans.DATA_USCITA AS uscita_network, a.RID, a.COD_REG, r.DESCRIZION AS regione, a.STATO, a.CITTA, 
                      m.DATAMOV, m.CODPREN, m.N_SEQ,(m.importo+m.tasse)as LORDO, m.IMPORTO, m.NETTO,m.TASSE, a.PROF_COMM, m.COMMISSIONE, m.TIPOMOV, c.DAREAVERE, c.DESCRIZIO, 
                      m.FORMAPAG, m.DATAPAG, m.COD_LOCALE, b.CODPROV, b.NOME AS intestatario,
s.DATAPART AS partenza_andata_ultimapratica,
i.PARTENZA AS porto_andata_ultimapratica,
s.FORMULA AS formula_andata_ultimapratica,
s.TIPOTK AS tipotk, b.RECAPITO, bi.DATA_EMISS AS data_emissione_biglietto,
l.MACROREGIONE AS macroregione,
b.codonline as codice_BTS

FROM dbo.movimenti AS m 
INNER JOIN dbo.agenzi AS a ON m.CODAGE = a.CODAGE 
LEFT OUTER JOIN dbo.agenzie_network_storico AS ans ON ans.CODAGE = a.CODAGE 
LEFT OUTER JOIN  dbo.agenzie_network AS an ON an.COD_NETWORK = ans.COD_NETWORK 
INNER JOIN dbo.causalimovim AS c ON c.TIPOMOV = m.TIPOMOV 
INNER JOIN dbo.region AS r ON r.COD_REG = a.COD_REG 
INNER JOIN dbo.biglie AS b ON m.CODPREN = b.CODPREN  
INNER JOIN dbo.seqbig AS s ON m.CODPREN = s.CODPREN AND s.N_SEQ = 1 
INNER JOIN dbo.itiner AS i ON i.CODITINERA = s.CODITINERA 
INNER JOIN corse co ON s.codcorsa = co.codcorsa
INNER JOIN configlinee cl ON cl.cod_cfg_linea = co.cod_cfg_linea
INNER JOIN linee l ON l.codlin = cl.codlin
LEFT OUTER JOIN dbo.biglietti AS bi ON bi.CODPREN = m.CODPREN AND bi.N_SEQ = m.N_SEQ AND bi.N_MOD = m.N_MOD AND bi.RIEMESSO = 0
WHERE b.annota <> 'ANNULLATA DA BATCH'

GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Altering [dbo].[v_jb_movcassadettbigl]'
GO
ALTER VIEW dbo.v_jb_movcassadettbigl
WITH ENCRYPTION AS
SELECT     m.IDPOSTAZIONE, m.CODTURNO, m.ORASECONDI, m.NUMBIGL, m.TIPOMOV, m.RIF_BIGLIETTO_OLD, m.CODSCO, m.CATKEY, 
                      m.CODCORSA_PARTENZA, m.CODITINERA, m.QTA, m.ISAR, m.IMPORTO, m.IMPONIBILE, m.IMPOSTA, m.IMP_ESENTE, m.DIR_TAX_IMPONIBILE, 
                      m.DIR_TAX_IMPOSTA, m.CODIVA, m.FORMAPAG, m.GRATUITI, m.NUM_IMBARCO, m.CODVAL, d.CODAGE, d.NUMVOUCHER, d.NUMFAT, 
                      d.IDCLIENTE AS codcliente, ci.COGNOME + ' ' + ci.NOME AS nominativo, d.TARGA, t.ID_TESSERA, t.CODCOMP AS CODCOMP_ABB, 
                      t.COGNOME AS COGNOME_ABB, t.NOME AS NOME_ABB, t.INDIRIZZO AS INDIRIZZO_ABB, t.CITTA AS CITTA_ABB, t.PIVA AS PIVA_ABB, 
                      t.CODICEFISCALE AS CODICEFISCALE_ABB, d.BIGLMANUALE, ci.CODICEFISCALE AS codfiscale, d.VEI_RES, d.VEI_LUNG, c.CODNAV, 
                      c.COD_CFG_LINEA, c.ORAARRI, c.CODLIST, c.CODTAR, c.DATAPART, c.ORAPART, c.CODNAV_INIZIALE, i.DESCRIZION AS linea, 
                      ci.INDIRIZZO AS cli_indirizzo, ci.CITTA AS cli_citta, ci.PIVA AS cli_piva, ci.COGNOME AS cli_cognome, ci.NOME AS cli_nome, a.NOME AS age_ragsoc, 
                      a.INDIRIZZO AS age_indirizzo, a.CITTA AS age_citta, a.PIVA AS age_piva, cs.DESCRIZIONE AS tariffa, IVA.DESCRIZIONE AS DESCIVA, 
                      CAT.DESCRIZION AS CATEGORIA, cs.IS_PASSAGGIO_TESSERA
FROM         dbo.jb_movcassabigl AS m WITH (NOLOCK) LEFT OUTER JOIN
                      dbo.corse AS c WITH (NOLOCK) ON c.CODCORSA = m.CODCORSA_PARTENZA LEFT OUTER JOIN
                      dbo.itiner AS i WITH (NOLOCK) ON i.CODITINERA = c.CODTRATTA LEFT OUTER JOIN
                      dbo.jb_MovDettBigl AS d WITH (NOLOCK) ON d.NUMBIGL = m.NUMBIGL LEFT OUTER JOIN
                      dbo.v_jb_abbonamenti_clienti AS t WITH (NOLOCK) ON t.ID_TESSERA = d.ID_TESSERA LEFT OUTER JOIN
                      dbo.clienti AS ci WITH (NOLOCK) ON ci.IDCLIENTE = d.IDCLIENTE LEFT OUTER JOIN
                      dbo.agenzi AS a WITH (NOLOCK) ON a.CODAGE = d.CODAGE INNER JOIN
                      dbo.jb_categoSconti AS cs WITH (NOLOCK) ON cs.CODSCO = m.CODSCO AND cs.CATKEY = m.CATKEY INNER JOIN
                      dbo.iva AS IVA WITH (NOLOCK) ON IVA.CODIVA = m.CODIVA INNER JOIN
                      dbo.catego AS CAT WITH (NOLOCK) ON CAT.CATKEY = m.CATKEY
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Altering [dbo].[v_jb_dettasseturno]'
GO
/* View
 VM 08-08-2012 - Aggiornamento alla nuova struttura
 AM 08/10/2009 -- Gestione del codcorsa in jb_movcassadettbigl*/
ALTER VIEW dbo.v_jb_dettasseturno
WITH ENCRYPTION AS
SELECT     mv.IDPOSTAZIONE, mv.CODTURNO, mv.NUMBIGL, mv.FORMAPAG, mv.CODITINERA, mv.DATAPART, mv.QTA AS quantita, dt.CATKEY, dt.CODSCO, 
                      dt.CODTASSA, dt.TASSA, dt.IVA, dt.ANNULLATO, td.DESCRIZIONE
FROM         dbo.v_jb_movcassadettbigl AS mv WITH (nolock) INNER JOIN
                      dbo.jb_DetTax AS dt WITH (nolock) ON mv.NUMBIGL = dt.NUMBIGL INNER JOIN
                      dbo.tasse_diritti AS td WITH (nolock) ON dt.CODTASSA = td.CODTASSA
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Altering [dbo].[v_sg_jb_movimenti]'
GO
/* CM 2013-12-10 - Eliminato codcarrello*/
ALTER VIEW dbo.v_sg_jb_movimenti
WITH ENCRYPTION AS
SELECT     m.IDPOSTAZIONE, m.CODTURNO, m.ORASECONDI, m.NUMBIGL, m.TIPOMOV, m.RIF_BIGLIETTO_OLD, m.CODSCO, m.CATKEY, 
                      m.CODCORSA_PARTENZA, m.CODITINERA, m.QTA, m.ISAR, m.IMPORTO, m.IMPONIBILE, m.IMPOSTA, m.IMP_ESENTE, m.DIR_TAX_IMPONIBILE, 
                      m.DIR_TAX_IMPOSTA, m.CODIVA, m.FORMAPAG, m.GRATUITI, m.NUM_IMBARCO, m.CODVAL, m.CODAGE, m.NUMVOUCHER, m.NUMFAT, m.codcliente, 
                      m.nominativo, m.TARGA, m.BIGLMANUALE, m.codfiscale, m.VEI_RES, m.VEI_LUNG, m.CODNAV, m.COD_CFG_LINEA, m.ORAARRI, m.CODLIST, 
                      m.CODTAR, m.DATAPART, m.ORAPART, m.CODNAV_INIZIALE, m.linea, m.cli_indirizzo, m.cli_citta, m.cli_piva, m.cli_cognome, m.cli_nome, 
                      m.age_ragsoc, m.age_indirizzo, m.age_citta, m.age_piva, m.tariffa, ISNULL(t.IMPORTO_TASSE, 0.00) AS IMPORTO_TASSE, 
                      ISNULL(d.IMPORTO_DIRITTI, 0.00) AS IMPORTO_DIRITTI, ISNULL(a.IMPORTO_ASSICURAZIONE, 0.00) AS IMPORTO_ASSICURAZIONE
FROM         dbo.v_jb_movcassadettbigl AS m LEFT OUTER JOIN
                      dbo.v_sg_jb_tassemovimenti AS t ON t.NUMBIGL = m.NUMBIGL LEFT OUTER JOIN
                      dbo.v_sg_jb_dirittimovimenti AS d ON d.NUMBIGL = m.NUMBIGL LEFT OUTER JOIN
                      dbo.v_sg_jb_assicurazionemovimenti AS a ON a.NUMBIGL = m.NUMBIGL
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Altering extended properties'
GO
EXEC sp_updateextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[41] 4[20] 2[35] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "m"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 125
               Right = 242
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "c"
            Begin Extent = 
               Top = 6
               Left = 280
               Bottom = 125
               Right = 463
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "i"
            Begin Extent = 
               Top = 126
               Left = 38
               Bottom = 245
               Right = 221
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "d"
            Begin Extent = 
               Top = 126
               Left = 259
               Bottom = 245
               Right = 442
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t"
            Begin Extent = 
               Top = 246
               Left = 38
               Bottom = 365
               Right = 246
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "ci"
            Begin Extent = 
               Top = 366
               Left = 38
               Bottom = 485
               Right = 278
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "a"
            Begin Extent = 
               Top = 486
               Left = 38
               Bottom = 605
               Right = 234
            End
            DisplayFlags = 280
            TopColumn = 0
         End
 ', 'SCHEMA', N'dbo', 'VIEW', N'v_jb_movcassadettbigl', NULL, NULL
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
EXEC sp_updateextendedproperty N'MS_DiagramPane2', N'        Begin Table = "cs"
            Begin Extent = 
               Top = 486
               Left = 272
               Bottom = 605
               Right = 466
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "IVA"
            Begin Extent = 
               Top = 246
               Left = 284
               Bottom = 361
               Right = 468
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "CAT"
            Begin Extent = 
               Top = 606
               Left = 38
               Bottom = 721
               Right = 213
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'SCHEMA', N'dbo', 'VIEW', N'v_jb_movcassadettbigl', NULL, NULL
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
EXEC sp_updateextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "p"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 125
               Right = 221
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "c"
            Begin Extent = 
               Top = 6
               Left = 492
               Bottom = 125
               Right = 675
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "cc"
            Begin Extent = 
               Top = 6
               Left = 713
               Bottom = 125
               Right = 896
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "cs"
            Begin Extent = 
               Top = 124
               Left = 260
               Bottom = 243
               Right = 455
            End
            DisplayFlags = 280
            TopColumn = 11
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 2085
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'SCHEMA', N'dbo', 'VIEW', N'v_jb_tariffe', NULL, NULL
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
EXEC sp_updateextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[34] 4[28] 2[30] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "m"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 125
               Right = 242
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t"
            Begin Extent = 
               Top = 6
               Left = 280
               Bottom = 95
               Right = 463
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "d"
            Begin Extent = 
               Top = 96
               Left = 280
               Bottom = 185
               Right = 463
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "a"
            Begin Extent = 
               Top = 126
               Left = 38
               Bottom = 215
               Right = 262
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'SCHEMA', N'dbo', 'VIEW', N'v_sg_jb_movimenti', NULL, NULL
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating extended properties'
GO
EXEC sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = -25
         Left = 0
      End
      Begin Tables = 
         Begin Table = "mv"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 184
               Right = 243
            End
            DisplayFlags = 280
            TopColumn = 17
         End
         Begin Table = "dt"
            Begin Extent = 
               Top = 6
               Left = 281
               Bottom = 121
               Right = 456
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "td"
            Begin Extent = 
               Top = 179
               Left = 38
               Bottom = 294
               Right = 239
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'SCHEMA', N'dbo', 'VIEW', N'v_jb_dettasseturno', NULL, NULL
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
EXEC sp_addextendedproperty N'MS_DiagramPaneCount', 1, 'SCHEMA', N'dbo', 'VIEW', N'v_jb_dettasseturno', NULL, NULL
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT>0 BEGIN
PRINT 'The database update succeeded'
COMMIT TRANSACTION
END
ELSE PRINT 'The database update failed'
GO
DROP TABLE #tmpErrors
GO
